package com.atguigu.w_threadPool;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Test01 {
    public static void main(String[] args) {
        // 创建一个容量为5的线程池
        ExecutorService threadPool = Executors.newFixedThreadPool(5);

        // 创建只有一个线程的线程池
        ExecutorService executor = Executors.newSingleThreadExecutor();

        // 创建一个可以自动扩容的线程池
        ExecutorService cachedThreadPool = Executors.newCachedThreadPool();

        try {
                System.out.println(Integer.MAX_VALUE);
            for (int i = 0; i < 10; i++) {
                cachedThreadPool.execute(()->{
                    System.out.println(Thread.currentThread().getName()+"...为顾客服务。。。");
                });
            }
        } finally {
            threadPool.shutdown();
        }
    }
}
